unit ImportProgressGui;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  TfrmImportProgress = class(TForm)
    ProgressBar: TProgressBar;
    btnAbort: TButton;
    lblImportPrices: TLabel;
    lblAmount: TLabel;
    lblTotal: TLabel;
    procedure btnAbortClick(Sender: TObject);
  private
  public
    AbortedByUser: Boolean;

    constructor Create(AOwner: TComponent; text: String; amount: Integer); reintroduce;
    procedure Advance;
    procedure Change(text: String; amount: Integer);
    procedure SetCounter(amount: Integer);
  end;

var
  frmImportProgress: TfrmImportProgress;

implementation

{$R *.dfm}

constructor TfrmImportProgress.Create(AOwner: TComponent; text: String; amount: Integer);
begin
  inherited Create(AOwner);
  AbortedByUser := false;
  lblTotal.Caption := 'out of ' + IntToStr(amount) + ' ' + text;
  ProgressBar.Max := amount;
end;

procedure TfrmImportProgress.Advance;
begin
  ProgressBar.StepIt;
  lblAmount.Caption := IntToStr(StrToInt(lblAmount.Caption) + 1);
end;

procedure TfrmImportProgress.SetCounter(amount: Integer);
begin
  ProgressBar.Position := amount;
  lblAmount.Caption := IntToStr(amount);
end;

procedure TfrmImportProgress.btnAbortClick(Sender: TObject);
begin
  AbortedByUser := true;
end;

procedure TfrmImportProgress.Change(text: string; amount: Integer);
begin
  ProgressBar.Position := 0;
  ProgressBar.Max := amount;
  lblAmount.Caption := '0';
  lblTotal.Caption := 'out of ' + IntToStr(amount) + ' ' + text;
end;

end.

